package cn.dliyy.warehouse.service;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import cn.dliyy.base.dao.HQL;
import cn.dliyy.base.service.CommonService;
import cn.dliyy.warehouse.bean.Category;
import cn.dliyy.warehouse.dao.EntityDao;

@Service
public class CategoryService extends CommonService{
	@Resource
	private EntityDao entityDao;
	@Resource
	private HQL hql;

	@Transactional
	public List<Object> getCategoryList() {
		StringBuffer sff = new StringBuffer();
		sff.append(hql.getListHQL(Category.class)).append(" where a.pid='0'");
		List<Object> list = entityDao.createQuery(sff.toString());
		return list;
	}

	public List<Object> getCategoryList(String pid) {
		StringBuffer sff = new StringBuffer();
		sff.append("from ").append(Category.class.getSimpleName()).append(" a ").append("where a.pid='" + pid + "'");
		List<Object> list = entityDao.createQuery(sff.toString());
		return list;
	}

	public void save(Category category) {
		entityDao.save(category);
	}

	public void update(Category category) {
		entityDao.update(category);
	}

	public void delete(Category category) {
		entityDao.delete(category);
	}
}
